package com.juku2024.juku.model

import android.os.Parcel
import android.os.Parcelable

class CommonModel() : Parcelable{
    var id: Long = 0L
    var name: String? = null
    var subtitle: String? = null
    var description: String? = null
    var pic: String? = null
    // 图片右下角内容 只提供一个字段
    var update_progress: String? = null
    var score: String? = null
    // 主演
    var actor: String? = null
    // 导演
    var director: String? = null
    // 清晰度
    var attributes: String? = null
    var url: String? = null
    var categoryId: Int = 0
    var year: String? = null
    var isWatching = false
    // 最新集数
    var theLastEpisode: Int? = null
    // 是否有更新
    var isVideoUpdate: Boolean? = false
    var isSelect = false
    /** 是否是短剧，true：是 */
    var sp = false

    constructor(parcel: Parcel) : this() {
        id = parcel.readLong()
        name = parcel.readString()
        subtitle = parcel.readString()
        description = parcel.readString()
        pic = parcel.readString()
        update_progress = parcel.readString()
        score = parcel.readString()
        actor = parcel.readString()
        director = parcel.readString()
        attributes = parcel.readString()
        url = parcel.readString()
        categoryId = parcel.readInt()
        year = parcel.readString()
        isWatching = parcel.readByte() != 0.toByte()
        theLastEpisode = parcel.readValue(Int::class.java.classLoader) as? Int
        isVideoUpdate = parcel.readValue(Boolean::class.java.classLoader) as? Boolean
        isSelect = parcel.readByte() != 0.toByte()
        sp = parcel.readByte() != 0.toByte()
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeLong(id)
        parcel.writeString(name)
        parcel.writeString(subtitle)
        parcel.writeString(description)
        parcel.writeString(pic)
        parcel.writeString(update_progress)
        parcel.writeString(score)
        parcel.writeString(actor)
        parcel.writeString(director)
        parcel.writeString(attributes)
        parcel.writeString(url)
        parcel.writeInt(categoryId)
        parcel.writeString(year)
        parcel.writeByte(if (isWatching) 1 else 0)
        parcel.writeValue(theLastEpisode)
        parcel.writeValue(isVideoUpdate)
        parcel.writeByte(if (isSelect) 1 else 0)
        parcel.writeByte(if (sp) 1 else 0)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<CommonModel> {
        override fun createFromParcel(parcel: Parcel): CommonModel {
            return CommonModel(parcel)
        }

        override fun newArray(size: Int): Array<CommonModel?> {
            return arrayOfNulls(size)
        }
    }


}